package de.in.michael.unnamed.screen;

import de.in.michael.unnamed.GameComponent;
import de.in.michael.unnamed.InputHandler;
import de.in.michael.unnamed.gfx.Bitmap;

public class TitleScreen extends Screen
{
	private int select = 0;

	public void tick(InputHandler inputHandler)
	{
		super.tick(inputHandler);

		if (inputHandler.down.clicked)
		{
			if (select != 2)
			{
				select++;
			}
		}
		else if (inputHandler.up.clicked)
		{
			if (select != 0)
			{
				select--;
			}
		}
		else if (inputHandler.enter.clicked)
		{
			switch (select)
			{
				case 0 :
				{
					setScreen(new GameScreen());
					return;
				}
				case 1 :
				{
					setScreen(new OptionScreen());
					return;
				}
				case 2 :
				{
					System.exit(0);
					return;
				}
				default:
				{
					throw new RuntimeException("wrong menu option: " + select);
				}
			}
		}
	}

	public void render(Bitmap b)
	{
		super.render(b);

		b.drawString(GameComponent.NAME + " " + GameComponent.VERSION, 1, 1);
		b.drawString("Start", 10, 16);
		b.drawString("Options", 10, 24);
		b.drawString("Exit", 10, 32);

		switch (select)
		{
			case 0 :
			{
				b.drawString(">", 2, 16);
				return;
			}
			case 1 :
			{
				b.drawString(">", 2, 24);
				return;
			}
			case 2 :
			{
				b.drawString(">", 2, 32);
				return;
			}
		}
	}

	public void remove()
	{
		super.remove();
	}
}
